package java_basics;


/**
 * @author 孤雪唯方
 * @date 2024/07/16
 * @description 简单运算
 */
public class SimpleOperation {

    /**
     * 加法
     * @param a
     * @param b
     */
    public static void add(int a, int b) {
        int result = a + b;
        System.out.println("The result of " + a + " added by " + b + " is " + result);
    }

    /**
     * 减法
     * @param a
     * @param b
     */
    public static void subtract(int a, int b) {
        int result = a - b;
        System.out.println("The result of " + a + " subtracted by " + b + " is " + result);
    }

    /**
     * 乘法
     * @param a
     * @param b
     */
    public static void multiply(int a, int b) {
        int result = a * b;
        System.out.println("The result of " + a + " multiplied by " + b + " is " + result);
    }

    /**
     * 除法
     * @param a
     * @param b
     */
    public static void divide(int a, int b) {
        if (b == 0) {
            System.out.println("Cannot divide by zero");
            return;
        }
        int result = a / b;
        System.out.println("The result of " + a + " divided by " + b + " is " + result);

    }


    /**
     * 求余
     * @param a
     * @param b
     */
    public static void modulus(int a, int b) {
        int result = a % b;
        System.out.println("The remainder of " + a + " divided by " + b + " is " + result);
    }

    public static void main(String[] args) {
        add(1, 2);
        subtract(5, 3);
        multiply(4, 6);
        divide(10, 2);
        divide(10, 0);
        modulus(10, 3);
        System.out.println("一次测试结束");
    }
}
